import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:high_help_apps/common/widgets/common/icon_menu/icon_menu_item.dart';
import '../../../common/widgets/common/icon_menu/icon_menu.dart';

import 'home_logic.dart';
import 'home_state.dart';

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  final HomeLogic logic = Get.put(HomeLogic());
  final HomeState state = Get.find<HomeLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: _buildHomeMain(),
    );
  }

  Widget _buildHomeMain() => ListView(
        physics: BouncingScrollPhysics(),
        // padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
        children: [
          _buildIconMenu(),
        ],
      );

  // IconMenu
  Widget _buildIconMenu() {
    return IconMenu(
      iconList: [
        IconMenuItem(
          iconLink: 'assets/images/icons/iconnav/subject_help.png',
          title: '学习互助',
          onPressed: () {},
        ),
        IconMenuItem(
          iconLink: 'assets/images/icons/iconnav/xinling_help.png',
          title: '心灵互助',
          onPressed: () {},
        ),
        IconMenuItem(
          iconLink: 'assets/images/icons/iconnav/life_help.png',
          title: '生活互助',
          onPressed: logic.enterLifeHelp,
        ),
        IconMenuItem(
          iconLink: 'assets/images/icons/iconnav/work_hard.png',
          title: '勤工俭学',
          onPressed: () {},
        ),
        IconMenuItem(
          iconLink: 'assets/images/icons/iconnav/share.png',
          title: '信息共享',
          onPressed: () {},
        ),
      ],
    );
  }



  @override
  void dispose() {
    Get.delete<HomeLogic>();
    super.dispose();
  }
}
